package com.xch.service;

import com.xch.bean.Courier;
import com.xch.bean.User;
import com.xch.dao.BaseCourierDao;
import com.xch.dao.BaseUserDao;
import com.xch.dao.impl.CourierDaoMysql;
import com.xch.dao.impl.UserDaoMysql;
import com.xch.exception.DuplicateCodeException;

import java.util.List;

public class UserService {
    private static BaseUserDao dao = new UserDaoMysql();

    public static List<User> findAll(boolean limit, int offset, int pageNumber){
        return dao.findAll(limit, offset, pageNumber);
    }
    public static int total(){
        return dao.total();
    }

    public static User findByPhone(String userPhone){
        return dao.findByPhone(userPhone);
    }

    public static boolean insert(User u){
        try {
            boolean flag = dao.insert(u);
            return flag;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return false;
    }

    public static boolean update(int id,User u){
        return dao.update(id,u);
    }

    public static boolean delete(int id){
        return dao.delete(id);
    }
}
